package com.study.config;

import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

/**
 * @desc:
 * @author: panxiyi
 * @date: 2023/5/16 9:29 上午
 */

public class MyImportSelector implements ImportSelector {
    // 实现对导入源的编程式处理，谁导入我，我就看谁的"户口"，把对应的bean选择性设置返回。
    @Override
    public String[] selectImports(AnnotationMetadata metadata) {
        System.out.println("====================");

        System.out.println(metadata.getClassName());
        System.out.println(metadata.hasAnnotation("org.springframework.context.annotation.Configuration"));

        System.out.println("====================");
        return new String[]{"com.study.bean.Dog", "com.study.bean.Cat"};
    }
}
